#ifndef HUBWIDGET_H
#define HUBWIDGET_H

#include <QWidget>
#include "applnk.h"
#include "hublnkhandler.h"

namespace Ui {
class HubWidget;
}

class HubWidget : public QWidget
{
    Q_OBJECT

public:
    static HubWidget* get_instance();
    ~HubWidget();

    inline void push_back_lnk(const QString& absolute_path)
    {
        hub_lnk_handler->add_lnk(hub_lnk_handler->get_size(), absolute_path);
    }
    void refresh_all();
    void update_and_show(int center_x);
    void static open_file(const QString& );
    inline QWidget* get_main_widget() {return main_widget_;}

private:
    explicit HubWidget(QWidget *main_widget);
    // 各种事件
    void paintEvent(QPaintEvent *);
    void mousePressEvent(QMouseEvent *);
    void mouseReleaseEvent(QMouseEvent *);
    void mouseMoveEvent(QMouseEvent *);
    void dragEnterEvent(QDragEnterEvent *);
    void dropEvent(QDropEvent *);

    Ui::HubWidget *ui;
    bool this_is_clicked;
    int pointer_x;
    HubLNKHandler* hub_lnk_handler;  // 快捷方式管理器
    QWidget* main_widget_;  // 主界面

signals:
    void clicked_space();
};

#endif // HUBWIDGET_H
